package com.tanhua.model.domian;


import lombok.Data;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Data
public class UserYearData implements Serializable {

    private String title;
    private Integer amount;

    public static List<UserYearData> initRegistered(List<Analysis> list){
        ArrayList<UserYearData> userYearDataS = new ArrayList<>();
        for (Analysis analysis : list) {
            UserYearData data = new UserYearData();
            data.setTitle(new SimpleDateFormat("yyyy-MM-dd").format(analysis.getCreated()));
            data.setAmount(analysis.getNumRegistered());
            userYearDataS.add(data);
        }
          return userYearDataS;
    }

   public static List<UserYearData> initActive(List<Analysis> list){
        ArrayList<UserYearData> userYearDataS = new ArrayList<>();
        for (Analysis analysis : list) {
            UserYearData data = new UserYearData();
            data.setTitle(new SimpleDateFormat("yyyy-MM-dd").format(analysis.getCreated()));
            data.setAmount(analysis.getNumActive());
            userYearDataS.add(data);
        }
        return userYearDataS;
    }

    public static List<UserYearData> initRetention1d(List<Analysis> list){
        ArrayList<UserYearData> userYearDataS = new ArrayList<>();
        for (Analysis analysis : list) {
            UserYearData data = new UserYearData();
            data.setTitle(new SimpleDateFormat("yyyy-MM-dd").format(analysis.getCreated()));
            data.setAmount(analysis.getNumRetention1d());
            userYearDataS.add(data);
        }
        return userYearDataS;
    }

}
